package edu.nf.ch05.web;

import edu.nf.ch05.entity.User;
import edu.nf.ch05.web.vo.ResultVO;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangl
 * @date 2025/5/13
 */
//@Controller
//新版本加入了@RestController注解，
//不需要在每个方法上显示标注@ResponseBody注解
@RestController
public class UserController extends BaseController {

    @GetMapping("/user")
    /**
     * 这个注解用于标识返回值将序列化为json响应
     */
    //@ResponseBody
    public ResultVO<User> getUser() {
        User user = new User();
        user.setUid(1);
        user.setUsername("user1");
        user.setAge(20);
        return success(user);
    }
}